import { createApp } from 'vue'
import router from './router'
import { store, key } from '@/store'
import ElementPlus from 'element-plus'
import resetForm from './utils/resetForm'
import myconfirm from './utils/myconfirm'
import "@/style/index.less"
import objCopy from './utils/objCopy'
import moment from 'moment'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import './permission'
import 'element-plus/dist/index.css'
import vue3SeamlessScroll from "vue3-seamless-scroll";
import locale from 'element-plus/lib/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'virtual:svg-icons-register'
import '@/style/index.scss'
import components from '@/components/index';
import App from './App.vue'
// import { cssSeamlessScroll } from "vue3-seamless-scroll";
const pinias = createPinia()
pinias.use(piniaPluginPersistedstate)
const app = createApp(App);
app.config.globalProperties.$resetForm = resetForm
app.config.globalProperties.$formatDateTime = (datetime: string): string => {
  const date = new Date(datetime);
  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
  const day = date.getDate().toString().padStart(2, '0');
  const hour = date.getHours().toString().padStart(2, '0');
  const minute = date.getMinutes().toString().padStart(2, '0');
  return `${year}-${month}-${day} ${hour}:${minute}`;
};
app.config.globalProperties.$myconfirm = myconfirm
app.config.globalProperties.$objCopy = objCopy
app.config.globalProperties.$moment = moment
app.use(router).use(store, key).use(pinias).use(ElementPlus, { locale }).mount('#app')
Object.keys(components).forEach((name) => {
  app.component(name, components[name])
})
Object.keys(ElementPlusIconsVue).forEach((key) => {
  app.component(key, ElementPlusIconsVue[key as keyof typeof ElementPlusIconsVue])
})
